<?php
// 前台学校安全信息管理模块
class AqxxAction extends CommonAction {
	function _filter(&$map){
		$map['id'] = array('egt',1);
		$map['sName'] = array('like',"%".$_POST['sName']."%");
		if(0!=$_SESSION['dwid'])$map['dwid'] = array('eq',$_SESSION['dwid']);
	}
	
	public function index() {
        //列表过滤器，生成查询Map对象
        $map = $this->_search('vaqxx');
        if (method_exists($this, '_filter')) {
            $this->_filter($map);
        }
        $name = 'vaqxx';
        $model = D($name);
        if (!empty($model)) {
            $this->_list($model, $map);
        }
        $this->display();
        return;
    }
	//更新页面显示
	function edit() {
        $model = D('vaqxx');
        $id = $_REQUEST ['id'];
		$id = 0==$_SESSION['dwid']?$_REQUEST['id']:$_SESSION['dwid'];
        $vo = $model->where('dwid='.$id)->find();
        $this->assign('vo', $vo);
        $this->display();
    }
	//不动产更新操作
	function update(){
		$model = D('Aqxx');	
		$dwid = 0==$_SESSION['dwid']?$_POST['dwid']:$_SESSION['dwid'];
        if (false !== $model->create()) {
			$list = $model->where('dwid='.$dwid)->save();
			if(false!==$list){
				$this->assign('jumpUrl', Cookie::get('_currentUrl_'));
				$this->success('编辑成功!',true);
			}else{
				$this->error('编辑失败!',true);
			}
        } else {
           $this->error($model->getError(),true);
        }
	}
	public function forbid() {
        $model = D('Aqxx');
        $id = $_REQUEST ['id'];
        $condition = array('dwid' => array('in', $id));
		$list = $model->forbid($condition);
        if ($list !== false) {
            $this->assign("jumpUrl", $this->getReturnUrl());
            $this->success('状态禁用成功');
        } else {
            $this->error('状态禁用失败！');
        }
        
    }
	function resume() {
        $model = D('Aqxx');
        $id = $_GET ['id'];
        $condition = array('dwid' => array('in', $id));
        if (false !== $model->resume($condition)) {
            $this->assign("jumpUrl", $this->getReturnUrl());
            $this->success('状态恢复成功！');
        } else {
            $this->error('状态恢复失败！');
        }
    }
}
?>